package com.dahua.messagesyncsh.entity;

import com.dahua.messagesyncsh.service.Impl.SensorDataServiceImpl;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;
import lombok.extern.slf4j.Slf4j;

@Data
@NoArgsConstructor
@AllArgsConstructor
@SuperBuilder
@Slf4j
public class SensorDataAbbreviation {
    private Long id;
    private Integer uploadStatus;
    private Integer stationId;
    private String time;
    private Integer eqId;
    private Integer vibSensorNo;
    private String timeSigFile;
    private String fftFile;
    private String psdFile;
    private String envelopeFile;
    private String cepFile;
    private String octaveFile;
    private Double rms;
    private Double arms;

    public boolean isCollision(SensorDataAbbreviation abbreviation, SensorDataServiceImpl.Type type) {
        switch (type) {
            case CHART_FILE:
                if (this.timeSigFile != null && abbreviation.getTimeSigFile() != null) {
                    return true;
                }
                if (this.fftFile != null && abbreviation.getFftFile() != null) {
                    return true;
                }
                if (this.psdFile != null && abbreviation.getPsdFile() != null) {
                    return true;
                }
                if (this.envelopeFile != null && abbreviation.getEnvelopeFile() != null) {
                    return true;
                }
                if (this.cepFile != null && abbreviation.getCepFile() != null) {
                    return true;
                }
                if (this.octaveFile != null && abbreviation.getOctaveFile() != null) {
                    return true;
                }
                break;
            case FEATURE:
                if (this.rms != null && abbreviation.getRms() != null) {
                    throw new RuntimeException("rms对比:已有" + this.rms + " 当前" + abbreviation.getRms());
                }
                if (this.arms != null && abbreviation.getArms() != null) {
                    throw new RuntimeException("arms对比:已有" + this.arms + " 当前" + abbreviation.getArms());
                }
                break;
        }
        return false;
    }
}
